﻿using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using XLua;
using UnityEngine.Events;

[Hotfix]
public class HotfixT<T>
{
    public void Test(T obj)
    {
        Debug.Log(obj);
    }
}

[Hotfix]
public class HotfixTest
{
    int version;
    public HotfixTest(int v)
    {
        this.version=v;
    }
    public void V(string str)
    {
        Debug.Log(version);
    }

    ~HotfixTest()
    {

    }
}

[Hotfix]
public class HotfixMain : MonoBehaviour
{
    HotfixTest test;

    event UnityAction myEvent;

    private int[] array=new int[] {1,2,3};
    public int Age
    {
        get
        {
            return 0;
        }
        set
        {
            Debug.Log(value);
        }
    }

    public int this[int index]
    {
        get
        {
            if(index>=0&&index<3)
            {
                return array[index];
            }
            else
                return -1;
        }
        set
        {
            if(index>=0&&index<3)
            {
                array[index]=value;
            }
        }
    }
    // Start is called before the first frame update
    void Start()
    {
        LuaMgr.GetInstance().Init();
        LuaMgr.GetInstance().DoLuaFile("Main");
        
        Speak(Add(10,20).ToString());

        test=new HotfixTest(1);
        test.V("banben");
        
        StartCoroutine(IE());
        
        Age=654;
        this[2]=1;

        myEvent+=myFunc;
        myEvent-=myFunc;

        HotfixT<string> t1=new HotfixT<string>();
        HotfixT<float> t2=new HotfixT<float>();
        t1.Test("c#");
        t2.Test(1);

    }

    // Update is called once per frame
    void Update()
    {
        
    }

    private int Add(int a,int b)
    {
        return 0;
    }

    public static void Speak(string str)
    {
        Debug.Log("没说出来");
    }

    IEnumerator IE()
    {
        while(true)
        {
            yield return new WaitForSeconds(1);
            Debug.Log("IE");
        }
    }

    public void myFunc()
    {

    }
}
